package com.augmentum.oes.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.augmentum.oes.exception.BaseException;

public final class PropertyUtil {
    /**
     * Get information for DB connection
     */
    private static Properties JDBCPt;
    private static Properties MsgPt;

    public static Properties load(String fileName) {
        Properties pt = new Properties();
        try {
            InputStream is = PropertyUtil.class.getClassLoader().getResourceAsStream(fileName);
            pt.load(is);
        } catch (IOException e) {
            throw new BaseException(40001);
        }
        return pt;
    }

    static {
        JDBCPt = load("app.properties");
        MsgPt = load("message.properties");
    }

    public static String getJDBCInfo(String key) {
        return JDBCPt.getProperty(key).trim();
    }

    public static String getMsg(String key) {
        return MsgPt.getProperty(key).trim();
    }
}
